<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
 
<jsp:include page="../blog/header.jsp"></jsp:include>
<link rel="stylesheet" href="${url }/edit/themes/default/default.css" />
<script charset="utf-8" src="${url }/edit/kindeditor-min.js"></script>
<script charset="utf-8" src="${url }/edit/lang/zh_CN.js"></script>
<script>
	KindEditor.ready(function(K) {
		var editor = K.create('textarea[name="t.content"]', {
			resizeType : 1,
			uploadJson : '${home}/blog/uploadFile',
			fileManagerJson : 'file/manage',
			allowFileManager : true,
			afterBlur: function(){this.sync();
			{
				
			}},
			items : [
				'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'code','bold', 'italic', 'underline',
				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', '|', 'emoticons', 'image','multiimage','link','insertfile']
		});
		prettyPrint();
	});
</script>

<script type="text/javascript">

	function checkSubmit() {
		if(document.getElementById("title").value=="" || document.getElementById("content").value=="")
		{
			document.getElementById("msg").innerHTML="文章的标题和内容都不能为空。。。。。";
			return;
		}
		document.getElementById("addorPre").submit();
	}
	function preview() {
		document.getElementById("type").value = "preview";
		document.getElementById("addorPre").submit();
	}
	function update() {
		document.getElementById("type").value = "update";
		document.getElementById("addorPre").submit();
	}
</script>
<script type="text/javascript">
	
	$(function(){
		var $tags=$("#inp");
		$(".tag").click(function(e){
			$tags.val($tags.val()+$(this).text()+",");
			$(this).remove();
			e.preventDefault();
		});
		$("#translate").click(function(){
			$.post('<%=request.getAttribute("url")%>/post/api/translate',{"content":$("#title").val()},function(data){
				if($("#result").length==0){
					$("#translate").after("<input name='alias' id='result' value='"+data+"'>");
				}
				else{
					$("#result").attr("value",data);
				}
			});
		});
	});
</script>
<div id="main">
	<s:property value="%{#data}"/>
	<div id="primary">
		<div id="content" role="main">
	${requestScope.msg}
	
	<h3 id="msg" ></h3>
	<form action="${home}/blog/<s:if test="title!=null">update</s:if><s:else>add</s:else>" class="form-horizontal" role="form" id="addorPre" method="post">
		    <input name="t.title" id="title" value="<s:property value="title"/>" size="60" maxlength="60"  class="col-xs-10 col-sm-5" type="text" placeholder="请输入文章标题">分类	<s:select name="t.blogSort.bsId" list="%{blogSort}" listValue="sortName" listKey="id">
		
	</s:select>		
		    <hr/>
			 <textarea
						name="t.content" cols="100" rows="8"  id="content"
						style="width:600px; height:500px; visibility:hidden; z-index: 9999;"><s:property value="content"/></textarea> 
	<hr/>
	<input value="" name="t.keywords" size="50" value="<s:property value="keywords"/>" id="inp"  placeholder="多个用, 隔开 (不能超过5个 )"/>
 
					<div class="clearfix form-actions">
						<div class="col-md-offset-3 col-md-9">
							<button class="btn btn-info" type="button" onClick="checkSubmit()">
								<i class="icon-ok bigger-110"></i>
								提        交
							</button>
						</div>
					</div>
					
	</form>
	
</div>
</div>
<jsp:include page="../public/footer.jsp"></jsp:include>
